<?php
class Departemen_model extends MY_Model {
	
    function Departemen_model(){
        parent::MY_Model();
        $this->load->database();
        $this->table_name = "departemen";
    }
    
    function select_last_entry($search_key=false, $limit=10, $offset=0, $orderby=""){
    	if ($search_key){
    		$this->db->like('dep_id', $search_key);
			$this->db->or_like('dep_nama', $search_key);
    	}
    	if ($orderby){
    		$this->db->order_by($orderby);
    	}
    	return $this->db->get($this->table_name, $limit, $offset);
    }
    
    function count_record(){
    	return $this->db->count_all_results($this->table_name);
    }
    
    function select_by_id($dep_id){
    	return $query = $this->db->get_where($this->table_name, array('dep_id' => $dep_id));
    }
}